﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Speed_of_live_and_deed
{
    class Thief
    {/// <summary>
     /// 各种常量
     /// </summary>
        public Rectangle Rectangle { get; set; }
        private int SpeedX;
        private int SpeedY;
        private int role=1;
        public Thief(Rectangle rec)
        {
            Rectangle = rec;
            SpeedX = 6;
            SpeedY = -3;
        }
        //绘制图案
        public void Draw(Graphics g)
        {
            g.TranslateTransform(dx: 0, dy: 5);
            // g.RotateTransform(angle);
            if (role==1)
            {
                g.DrawImage(Properties.Resources.photo1, Rectangle);
            }
            if (role == 2)
            {
                g.DrawImage(Properties.Resources.photo12, Rectangle);
            }
            if (role == 3)
            {
                g.DrawImage(Properties.Resources.photo13, Rectangle);
            }
            if (role == 4)
            {
                g.DrawImage(Properties.Resources.photo14, Rectangle);
            }
            // g.RotateTransform(angle);

        }
        /// <summary>
        /// 移动函数
        /// </summary>
        public void Move()
        {

            this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
            if (this.Rectangle.X <= 162 & this.Rectangle.X >= 162 & this.Rectangle.Y <= 354 & this.Rectangle.Y >= 354)
            {
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                SpeedX *= -1;
                role = 2;
            }

            if (this.Rectangle.X <= 200 & this.Rectangle.Y <= 318 & this.Rectangle.Y >= 318)
            {
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                SpeedX *= -1;
                role = 1;
            }
            if (this.Rectangle.X >= 324 & this.Rectangle.X <= 324 & this.Rectangle.Y <= 201 & this.Rectangle.Y >= 201)
            {
                SpeedX *= -1;
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                role = 2;

            }
            if (this.Rectangle.X >= 216 & this.Rectangle.X <= 216 & this.Rectangle.Y <= 147 & this.Rectangle.Y >= 147)
            {
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                SpeedX *= -1;
                role = 1;
            }
            if (this.Rectangle.X <= 390 & this.Rectangle.X >= 390 & this.Rectangle.Y <= 60)
            {
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                SpeedY *= -1;
                role = 3;
            }
            if (this.Rectangle.X <= 546 & this.Rectangle.X >= 546 & this.Rectangle.Y <= 138)
            {
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                //peedX *= -1;
                SpeedY *= -1;
                role = 1;
            }
            if (this.Rectangle.X >= 690 & this.Rectangle.X <= 690 & this.Rectangle.Y <= 66)
            {
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                //peedX *= -1;
                SpeedY *= -1;
                role = 3;
            }
            if (this.Rectangle.X >= 900 & this.Rectangle.X <= 900 & this.Rectangle.Y <= 171)
            {
                this.Rectangle = new Rectangle(900, 171, 50, 60);
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                SpeedX *= -1;
                role = 4;
            }
            if (this.Rectangle.X <= 216 & this.Rectangle.X >= 216 & this.Rectangle.Y >= 513)
            {
                this.Rectangle = new Rectangle(210, 510, 50, 60);
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                SpeedY *= -1;
                role = 2;
            }
            if (this.Rectangle.X <= 30 & this.Rectangle.Y <= 420 & this.Rectangle.Y >= 420)
            {
                this.Rectangle = new Rectangle(30, 420, 50, 60);
                SpeedX *= -1;
                this.Rectangle = new Rectangle(this.Rectangle.X + SpeedX, this.Rectangle.Y + SpeedY, 50, 60);
                    role = 1;
            }


        }

    }
}
